﻿Imports System

Partial Public Class Site1
    Inherits System.Web.UI.MasterPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            'If (CheckSession()) Then
            '    Dim ds As DataSet = Session("UserData")
            '    If Not (ds Is Nothing) Then
            '        lbNameUser.Text = ds.Tables(0).Rows(0).Item("Name").ToString()
            '        lbRoleUser.Text = ds.Tables(0).Rows(0).Item("Role_name").ToString()
            '    Else
            '        Response.Redirect("../Form/Logon.aspx", True)
            '    End If

            '    Dim drBooking As DataRow() = CType(Session("UserMenuRole"), DataSet).Tables(0).Select("Mode = 'Booking'") 'ให้ทำการ select เฉพาะ Mode Booking
            '    Dim Count As Integer = 1
            '    For Each dr As DataRow In drBooking
            '        If (dr("Show_Menu") & "" = "Y") Then
            '            EasymenuBooking.AddItem(New MenuItem("B" & Count.ToString(), dr.Item("Menu_name"), "", "../Form/" & dr("Path").ToString() & "?P1=" & dr("Edit_Menu").ToString() & "&P2=" & dr("Add_Menu").ToString() & "&P3=" & dr("Delete_Menu").ToString()))
            '            Count += 1
            '        End If
            '    Next
            '    Count = 1
            '    Dim drMaster As DataRow() = CType(Session("UserMenuRole"), DataSet).Tables(0).Select("Mode = 'Master'") 'ให้ทำการ select เฉพาะ Mode Master
            '    For Each dr As DataRow In drMaster
            '        If (dr("Show_Menu") & "" = "Y") Then
            '            EasymenuMaster.AddItem(New MenuItem("M" & Count.ToString(), dr.Item("Menu_name"), "", "../Form/" & dr("Path").ToString() & "?P1=" & dr("Edit_Menu").ToString() & "&P2=" & dr("Add_Menu").ToString() & "&P3=" & dr("Delete_Menu").ToString()))
            '            Count += 1
            '        End If
            '    Next
            '    Count = 1
            '    Dim drReport As DataRow() = CType(Session("UserMenuRole"), DataSet).Tables(0).Select("Mode = 'Report'") 'ให้ทำการ select เฉพาะ Mode Master
            '    For Each dr As DataRow In drReport
            '        If (dr("Show_Menu") & "" = "Y") Then
            '            EasymenuReport.AddItem(New MenuItem("R" & Count.ToString(), dr.Item("Menu_name"), "", "../Form/" & dr("Path").ToString() & "?P1=" & dr("Edit_Menu").ToString() & "&P2=" & dr("Add_Menu").ToString() & "&P3=" & dr("Delete_Menu").ToString()))
            '            Count += 1
            '        End If
            '    Next

            'End If
        End If
    End Sub
    Private Function CheckSession() As Boolean
        If ((Session("UserData") Is Nothing) Or (Session("Config") Is Nothing) Or (Session("UserMenuRole") Is Nothing) Or (Session("Role") Is Nothing)) Then
            Return False
        Else
            Return True
        End If
    End Function
End Class